package com.wsx.ones.gateway.server;

import com.wsx.ones.gateway.core.config.RouterConfig;
import com.wsx.ones.gateway.remote.RemoteService;
import com.wsx.ones.gateway.remote.netty.NettyRemoteServer;
import com.wsx.ones.gateway.remote.netty.NettyServerConfig;

/**
 * @author wangshuaixin
 * @Title: com.wsx.ones.gateway.server.GatewayServer
 * @Description: Gatewayserver
 * @date 2019/07/16
 */
public class GatewayServer {


    private final GatewayConfig gatewayConfig;
    private final NettyServerConfig nettyServerConfig;
    private final RouterConfig routerConfig;

    private RemoteService remoteService;

    public GatewayServer(GatewayConfig gatewayConfig,
                         NettyServerConfig nettyServerConfig,
                         RouterConfig routerConfig) {
        this.gatewayConfig = gatewayConfig;
        this.nettyServerConfig = nettyServerConfig;
        this.routerConfig = routerConfig;
    }


    public boolean initialize() {

        remoteService = new NettyRemoteServer(nettyServerConfig, routerConfig);
        return true;
    }


    public boolean start() {
        remoteService.start();
        return true;
    }

    public void shutdown() {
        remoteService.shutdown();
    }
}
